<template>
  <div class="homeOrder">
      <!-- 订单列表 -->
      <div class="order-list">
     <template v-for="(item,index) in orderItems">
        <div class="list clearfix" :key="index">
          <div class="list-tit">
            <span class="tit">订单号：{{item.orderSsn}}</span>
          </div>
          <div class="pImg fl">
           <img  src="../../assets/imgs/pdetail1.png" alt="">
          </div>
          <div class="pInfo fl">
           <p class="grey">{{item.userID}} <span></span></p>
           <p class="grey">订单金额： <span>{{item.orderAmt}}</span> </p>
           <p class="grey">订单日期： <span>{{formatDateDT(new Date(item.createTime),'yyyy-MM-dd')}}</span> </p>
         </div>
        </div>
        </template>
      </div>
  </div>
</template>

<script>
export default {
  beforeMount () {
    let that = this
    // 获取我的订单
    this.$http.post('http://218.104.153.143:8089/numberone-auth//busiOrderDtl/downOrderList.shtml', this.filters, { // 头文件及JSON格式设定
      headers: {'Content-Type': 'application/x-www-form-urlencoded'},
      emulateJSON: true
    }).then((data) => { // 数据获取成功
      that.orderItems = data.body.downOrderList.records
    }, (ne) => { // 数据获取失败
      this.$message({
        message: '数据获取失败',
        type: 'error',
        duration: 1000,
        showClose: false
      })
    })
  },
  data () {
    return {
      orderItems: [],
      filters: {
        pageSize: 100,
        pageNow: 1,
        token: this.$store.state.token
      }
    }
  },
  methods: {
    formatDateDT (date, fmt) {
      var o = {
        'M+': date.getMonth() + 1, // 月份
        'd+': date.getDate(), // 日
        'h+': date.getHours(), // 小时
        'm+': date.getMinutes(), // 分
        's+': date.getSeconds(), // 秒
        'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
        'S': date.getMilliseconds() // 毫秒
      }
      if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
      for (var k in o) { if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) }
      return fmt
    }
  }
}
</script>

<style lang="scss" type="stylesheet/scss">
.homeOrder{
    font-size: 12px;
  .order-list{
    background-color: #F6F6F6;
    margin-bottom: 60px;
    .btn{
      float: right;
      margin-top: 45px;
      margin-right: 16px;
    }
    .el-collapse-item__header{
      height:30px;
      line-height:30px;
    }
    .list{
      background-color:#FFF;
      text-align: left;
      position: relative;
      border-bottom: 1px solid #ccc;
      padding-bottom: 21px;
        .list-tit{
          height: 35px;
          line-height: 35px;
          margin-bottom: 21px;
          border-bottom: 1px solid #ccc;
          border-top: 1px solid #ccc;
          .tit{
            border-left: 3px solid #31BE2A;
            padding-left:5px;
          }
        }
        .pImg{
          margin-left: 11px;
          width:82px;
          height: 82px;
          overflow: hidden;
          border-radius: 50%;
          img{
            width:82px;
            height: 82px;
          }
          }
        .pInfo{
          margin-left: 20px;
          line-height: 26px;
          span{
            // color:red;
          }
          i{
            background-color: #44A439;
            color: #fff;
            border-radius: 2px;
            padding: 0 2px;
            margin-left: 10px;
          }
          .grey{
            color:#686868;
          }
        }
      }
    }
}
</style>
